
function [ x,P] = WRLSEstimator( x,P,v_sqr,y,w)
% weighted recursive least square estimator
%
%--------------------------------------------------------------------------
% Inputs:
%           x: estimates
%           P: covariance matrix
%           v_sqr: input variable, speed squre
%           y: output variable, total drag
% Outputs: 
%           x: new estimates 
%           P: new covariance matrix
%
%-------------------------TUNNING FACTORS----------------------------------
R = 1000;       % System Estimation Error
%--------------------------------------------------------------------------

H=w*[v_sqr 1]; 
y=w*y;
          
K = (H*P*H' + R)\(P*H');
x = x + K*(y - H*x);
P = P - K*H*P;

end

